/**
 * Generali Solutions d'assurances - Tous droits réservés &copy; 2007 - 2010
 */
package fr.generali.accueilclient.utils.jaxb;

import org.apache.commons.lang.StringUtils;

import com.sun.xml.bind.marshaller.NamespacePrefixMapper;

/**
 * @author Holmes Kelly
 */
public class AccueilClientNamespacePrefixMapper extends NamespacePrefixMapper {

    /**
     * Prefix CTX
     */
    private static final String PREFIX_CTX = "ctx";
    /**
     * Namespace Uri conversation
     */
    private static final String NAMESPACE_URI_CONVERSATION_1_0_CTX = "http://brique.generali.fr/conversation/1.0/ctx";

    /**
     * {@inheritDoc}
     */
    @Override
    public String getPreferredPrefix(String namespaceUri, String suggestion, boolean requirePrefix) {

        String preferredPrefix = StringUtils.EMPTY;

        if (requirePrefix) {
            if (NAMESPACE_URI_CONVERSATION_1_0_CTX.equals(namespaceUri)) {
                preferredPrefix = PREFIX_CTX;
            }

            return StringUtils.equalsIgnoreCase(suggestion, preferredPrefix) ? suggestion : preferredPrefix;
        }
        
        else{
            if (NAMESPACE_URI_CONVERSATION_1_0_CTX.equals(namespaceUri)) {
                preferredPrefix = PREFIX_CTX;
            }
        }

        return preferredPrefix;

    }

}
